<template>
    <div class="test">
        <!-- 头部Table页 -->
        <Row type="flex" justify="space-around" class="code-row-bg" v-if="positive == false">
            <Col span="24">
                <div class="tmpHeader">
                    <span :class="{active:typeStatus == item.value }" @click="changeTab(item.value) " v-for="(item,index) in tabList">{{ item.title }}
                        <span class="num" v-if="item.value == 2">{{ invalidNum }}</span>
                        <span class="num" v-if="item.value == 3">{{ positiveNum }}</span>
                    </span>
                </div>
            </Col>
        </Row>
        <div class="cueBox" v-if="typeStatus ==2 " >
            <div class="icon">
                <img src="../../../assets/images/error.png" alt="">
            </div>
            <div class="cue">
                <span class="s1">风险警告</span>
                <br />
                <span class="s2" v-if="typeStatus == 2" >请及时安排以下人员重新进行采集</span>
                <!-- <span class="s2" v-if="typeStatus == 3" >请及时安排以下人员进行流调，并按规定执行其他疫情防控流程</span> -->
            </div>
        </div>
        <!-- 查询内容 -->
        <Row style="margin-top:10px;">
            <Col :xs="24">
                <div class="margin-up-down" v-if="positive == false">
                    <Select v-model="info.taskId" style="width:130px" v-if="typeStatus ==1" clearable placeholder="任务名称">
                        <Option
                            v-for="item in tasklist"
                            :value="item.id"
                            :key="item.id"
                            style='text-align:center'
                        >{{ item.taskName }}</Option>
                    </Select>
                </div>
                <div class="margin-up-down" v-if="positive == false">
                    <Select v-model="info.taskLocationId" filterable style="width:130px" placeholder="采集点" clearable>
                        <Option
                            v-for="item in locationlist"
                            :value="item.id"
                            :key="item.id"
                            style='text-align:center'
                        >{{ item.locationName }}</Option>
                    </Select>
                </div>
                <div class="margin-up-down" v-if="positive == false">
                    <Select v-model="info.tubesStatus" style="width:130px" v-if="typeStatus ==1" placeholder="状态" clearable>
                        <Option value="5" style='text-align:center'>待核验</Option>
                        <Option value="6" style='text-align:center'>待检验</Option>
                        <Option value="4" style='text-align:center'>已出结果</Option>
                        <Option value="2" style='text-align:center'>已作废</Option>
                    </Select>
                </div>
                <!-- <div class="margin-up-down" v-if="positive == false">
                    <Select v-model="info.tubesStatus" style="width:130px" v-if="typeStatus ==2" placeholder="状态" clearable>
                        <Option value="2" style='text-align:center'>未处理</Option>
                        <Option value="3" style='text-align:center'>已重采</Option>
                    </Select>
                </div> -->
                <div class="margin-up-down" v-if="positive == false">
                    <Select v-model="info.diagnosisStatus" style="width:130px" v-if="typeStatus ==3" placeholder="状态" clearable>
                        <!-- <Option value="1" style='text-align:center'>未确诊，未流调</Option>
                        <Option value="2" style='text-align:center'>未确诊，已流调</Option>
                        <Option value="3" style='text-align:center'>已确诊，未流调</Option>
                        <Option value="4" style='text-align:center'>已确诊，已流调</Option> -->
                        <Option value="0" style='text-align:center'>未确诊</Option>
                        <Option value="1" style='text-align:center'>已确诊</Option>
                    </Select>
                </div>
                <div class="margin-up-down" v-if="positive == false">
                    <DatePicker v-if="typeStatus ==1" type="date" v-model="info.endTime" :options="options" placeholder="请选择完成样本日期" format="yyyy-MM-dd" placement="bottom-end" style="width: 200px"></DatePicker>
                </div>
                <div class="margin-up-down" v-if="positive == false && typeStatus ==1">
                    <Input
                        suffix="ios-search"
                        placeholder="封箱编号"
                        style="width: 200px"
                        v-model="info.boxCode"
                        clearable
                    />
                </div>
                <div class="margin-up-down" v-if="positive == false">
                    <Input
                        suffix="ios-search"
                        placeholder="样本编号"
                        style="width: 200px"
                        v-model="info.tubesCode"
                        clearable
                    />
                </div>
                <div class="margin-up-down" v-if="positive == false">
                    <Button type="primary" icon="ios-search" @click="loadPage(1)"></Button>
                </div>
                <div class="margin-up-down" v-if="positive == false">
                    <Button @click="changeTab(typeStatus)">
                        <i class = "iconfont icon-gengxin" style="font-size:14px;margin-right:5px"></i>
                    </Button>
                </div>
                <!-- <div class="margin-up-down" v-if="typeStatus ==3">
                    <Button type="primary" @click="download">
                        全部移交流调
                    </Button>
                </div> -->
                <div class="margin-up-down" v-if="positive == false">
                    <Button type="primary" @click="download">
                        按筛选条件导出
                    </Button>
                </div>
            </Col>
        </Row>
        <!-- 表格列表 -->
        <Row type="flex" justify="space-around" class="code-row-bg" style="margin-top:10px;">
            <Col span="24">
                <Table stripe :columns="columns" :data="datalist"></Table>
            </Col>
        </Row>
        <!-- 页码 -->
        <div class="page">
            <Page :total="count" :current='pageNo' :page-size="pageSize" show-total show-elevator @on-change="getdatalist" v-if="columns == column4"/>
            <Page :total="count" :current='pageNo' :page-size="pageSize" show-total show-elevator @on-change="loadPage" v-else/>
        </div>
        <div v-if="positive == true" style="text-align:center">
            <Button @click="back">
                返回
            </Button>
        </div>
        <!-- 移交流调弹窗 -->
        <Modal
			v-model="moveModal"
            title = "提示"
			:footer="null"
            :mask-closable="false"
            :width = '300'
            styles="padding: none;margin: none"
        >
        <!-- 控制弹窗右上角x号是否显示 :closable="false" -->
            <div class="txtword">
                执行后可在5G疫情调度管理平台上进行流调相关操作，是否确定要移交流调？
            </div>
            <div slot="footer" class="btn-group" style="text-align:center">
                <Button type="primary" @click="movesubmit" style="width:75px;height:35px;" :disabled='disabledSave'>
                    <Icon type="ios-checkmark" style="margin-right: 5px" />保存
                </Button>
                <Button @click="moveModal = false" style="width:75px;height:35px;">
                    <i class = "iconfont icon-butongyi" style="font-size:14px;margin-right:5px"></i>取消
                </Button>
            </div>
		</Modal>
        <!-- 提交确诊弹窗 -->
        <Modal
			v-model="confirmModal"
            title = "提示"
			:footer="null"
            :mask-closable="false"
            :width = '700'
            styles="padding: none;margin: none"
        >
            <div class="txtword">
                此操作执行后不可修改，是否确认该居民的确诊状态？
            </div>
            <div slot="footer" class="btn-group" style="text-align:center">
                <Button type="primary" @click="confirmsubmit(2)" style="height:35px;" :disabled='disabledWZZ'>
                    <Icon type="ios-checkmark" style="margin-right: 5px" />提交为无症状感染病例
                </Button>
                <Button type="primary" @click="confirmsubmit(1)" style="height:35px;" :disabled='disabledQZ'>
                    <Icon type="ios-checkmark" style="margin-right: 5px" />提交为确诊病例
                </Button>
                <Button type="primary" @click="confirmsubmit(3)" style="height:35px;" :disabled='disabledYY'>
                    <Icon type="ios-checkmark" style="margin-right: 5px" />提交为阴性病例
                </Button>
                <Button @click="confirmModal = false" style="width:75px;height:35px;">
                    <i class = "iconfont icon-butongyi" style="font-size:14px;margin-right:5px"></i>取消
                </Button>
            </div>
		</Modal>
        <!-- 忽略弹窗 -->
        <Modal
			v-model="neglectModal"
            title = "提示"
			:footer="null"
            :mask-closable="false"
            :width = '300'
            styles="padding: none;margin: none"
        >
            <div class="txtword">
                忽略后将删除该条记录，是否确定忽略？
            </div>
            <div slot="footer" class="btn-group" style="text-align:center">
                <Button type="primary" @click="neglectsubmit" style="width:75px;height:35px;" :disabled='disabledNeglect'>
                    <Icon type="ios-checkmark" style="margin-right: 5px" />确定
                </Button>
                <Button @click="neglectModal = false" style="width:75px;height:35px;">
                    <i class = "iconfont icon-butongyi" style="font-size:14px;margin-right:5px"></i>取消
                </Button>
            </div>
		</Modal>
    </div>
</template>

<script>
import api from "@/api/commonApi";
import { DatePicker } from "view-design";
import Utils from "@/utils";
export default {
    components:{
        DatePicker
    },
    data() {
        return {
            positive: false,
            typeStatus: 1,
            // tab列表
            tabList: [
                {
                    title: "样本列表",
                    value: 1,
                },
                {
                    title: "作废样本人员",
                    value: 2,
                },
                {
                    title: "阳性样本人员",
                    value: 3
                },

            ],
            info: {
                taskName: null,
                taskId: null,
                taskLocationId: null,
                tubesStatus: null,
                endTime: null,
                boxCode: null,
                tubesCode: null,
                diagnosisStatus: null,
            },
            tubesId: '',
            columns: [],
            datalist: [],
            column1: [
                {
                    title: "排序",
                    key: "iSum",
                    align: "center",
                    render: (h, params) => {
                        let iSum = (this.pageNo-1)*this.pageSize + params.index +1;
                        return h("span", iSum);
                    }
                },
                {
                    title: "样本编号",
                    key: "tubesCode",
                    align: "center"
                },
                {
                    title: "封箱编号",
                    key: "boxCode",
                    align: "center"
                },
                {
                    title: "采集点",
                    key: "locationName",
                    align: "center",
                    // width: 200
                },
                {
                    title: "采集地点",
                    key: "address",
                    align: "center",
                },
                {
                    title: "完成样本时间",
                    key: "endTime",
                    align: "center",
                },
                {
                    title: "采集人数（人）",
                    key: "collectNum",
                    align: "center"
                },
                {
                    title: "检验结果",
                    key: "result",
                    align: "center",
                    render:(h,params)=>{
                        let tubesStatus = params.row.tubesStatus
                        let result = ''
                        if(tubesStatus==4) {
                            result = params.row.result
                        } else {
                            result = '-'
                        }
                        return h('span', {
                            domProps: {
                                innerHTML: result
                            }
                        });
                    }
                },
                {
                    title: "样本状态",
                    key: "tubesStatus",
                    align: "center",
                    render:(h,params)=>{
                        let tubesStatus = params.row.tubesStatus
                        let tubesStatusName = ''
                        if(tubesStatus==2) {
                            tubesStatusName = '已作废'
                        } else if(tubesStatus==3) {
                            tubesStatusName = '医生端进行中'
                        } else if(tubesStatus==4) {
                            tubesStatusName = '已出结果'
                        } else if(tubesStatus==5) {
                            tubesStatusName = '待核验'
                        } else if(tubesStatus==6) {
                            tubesStatusName = '待检验'
                        }
                        return h('span', {
                            domProps: {
                                innerHTML: tubesStatusName
                            }
                        });
                    }
                },
                {
                    title: "设置",
                    key: "operate",
                    align: "center",
                    // width: 60,
                    render: (h, params) => {
                        let tubesId = params.row.tubesId;
                        let tubesStatus = params.row.tubesStatus
                        let result = params.row.result
                        let buttontxt = ''
                        if(tubesStatus == 5 || tubesStatus == 6 || result == '阴性') {
                            buttontxt = '详情'
                        }
                        if(result == '阳性') {
                            buttontxt = '处理'
                        }
                        if(tubesStatus==2) {
                            return h('span', {
                                domProps: {
                                    innerHTML: '-'
                                }
                            });
                        } else {
                            return h(
                                "a",
                                {
                                    attrs: {
                                        href: "javascript:void(0);"
                                    },
                                    style: {
                                        color: " #5362e1",
                                        width: "60px"
                                    },
                                    on: {
                                        click: () => {
                                            // 公用方法
                                            if(tubesStatus == 5 || tubesStatus == 6) {
                                                this.functionJS.queryNavgationTo(
                                                    this,
                                                    "/index/nucleicacid/test/personlist",
                                                    {
                                                        tubesId,
                                                    }
                                                );
                                            }
                                            if(result == '阴性') {
                                                this.functionJS.queryNavgationTo(
                                                    this,
                                                    "/index/nucleicacid/test/personlist",
                                                    {
                                                        tubesId,
                                                        result,
                                                    }
                                                );
                                            }
                                            if(result == '阳性') {
                                                this.positive = true
                                                this.typeStatus = 3
                                                this.columns = this.column4
                                                this.tubesId = tubesId
                                                this.getdatalist(1,tubesId)
                                            }
                                        }
                                    }
                                },
                                buttontxt
                            );
                        }
                    }
                }
            ],
            column2: [
                {
                    title: "排序",
                    key: "iSum",
                    align: "center",
                    render: (h, params) => {
                        let iSum = (this.pageNo-1)*this.pageSize + params.index +1;
                        return h("span", iSum);
                    }
                },
                {
                    title: "姓名",
                    key: "name",
                    align: "center"
                },
                {
                    title: "身份证号",
                    key: "idcard",
                    align: "center"
                },
                {
                    title: "手机号",
                    key: "telephone",
                    align: "center",
                    // width: 200
                },
                {
                    title: "采集点",
                    key: "locationName",
                    align: "center",
                    // width: 200
                },
                {
                    title: "采集地点",
                    key: "address",
                    align: "center",
                },
                {
                    title: "样本编号",
                    key: "tubesCode",
                    align: "center",
                },
                {
                    title: "采集时间",
                    key: "collectionTime",
                    align: "center",
                },
                {
                    title: "采集点联系人",
                    key: "contactName",
                    align: "center"
                },
                {
                    title: "联系电话",
                    key: "contactPhone",
                    align: "center"
                },
                {
                    title: "状态",
                    key: "tubesStatusName",
                    align: "center",
                    render:(h,params)=>{
                        let tubesStatus = params.row.tubesStatus
                        let tubesStatusName = ''
                        if(tubesStatus==2) {
                            tubesStatusName = '未处理'
                        } else if(tubesStatus==3) {
                            tubesStatusName = '已重采'
                        }
                        return h('span', {
                            domProps: {
                                innerHTML: tubesStatusName
                            }
                        });
                    }
                },
                {
                    title: "设置",
                    key: "operate",
                    align: "center",
                    // width: 60,
                    render: (h, params) => {
                        let tubesStatus = params.row.tubesStatus
                        let id = params.row.id
                        return [
                            tubesStatus == 2 ?
                            h(
                                "a",
                                {
                                    attrs: {
                                        href: "javascript:void(0);"
                                    },
                                    style: {
                                        color: " #5362e1",
                                        width: "60px"
                                    },
                                    on: {
                                        click: () => {
                                            this.neglectModal = true
                                            this.id = id
                                        }
                                    }
                                },
                                "忽略"
                            ) : '-',
                        ]
                    }
                }
            ],
            column3: [
                {
                    title: "排序",
                    key: "iSum",
                    align: "center",
                    width: 70,
                    render: (h, params) => {
                        let iSum = (this.pageNo-1)*this.pageSize + params.index +1;
                        return h("span", iSum);
                    }
                },
                {
                    title: "姓名",
                    key: "name",
                    align: "center"
                },
                {
                    title: "身份证号",
                    key: "idcard",
                    align: "center"
                },
                {
                    title: "手机号",
                    key: "telephone",
                    align: "center",
                    // width: 200
                },
                {
                    title: "采集点",
                    key: "locationName",
                    align: "center",
                    // width: 200
                },
                {
                    title: "采集地点",
                    key: "address",
                    align: "center",
                },
                {
                    title: "样本编号",
                    key: "tubesCode",
                    align: "center",
                },
                {
                    title: "采集时间",
                    key: "collectionTime",
                    align: "center",
                },
                {
                    title: "采集点联系人",
                    key: "contactName",
                    align: "center"
                },
                {
                    title: "联系电话",
                    key: "contactPhone",
                    align: "center"
                },
                // {
                //     title: "流调状态",
                //     key: "tubesStatusName",
                //     align: "center",
                //     render:(h,params)=>{
                //         let transferStatus = params.row.transferStatus
                //         let tubesStatusName = ''
                //         if(transferStatus==0) {
                //             tubesStatusName = '未流调'
                //         } else if(transferStatus==1) {
                //             tubesStatusName = '已流调'
                //         }
                //         return h('span', {
                //             domProps: {
                //                 innerHTML: tubesStatusName
                //             }
                //         })
                //     }
                // },
                {
                    title: "确诊结果",
                    key: "diagnosisStatus",
                    align: "center",
                    render:(h,params)=>{
                        let diagnosisStatus = params.row.diagnosisStatus
                        let diagnosisStatusName = ''
                        if(diagnosisStatus==0) {
                            diagnosisStatusName = '未处理'
                        } else if(diagnosisStatus==1) {
                            diagnosisStatusName = '确诊病例'
                        } else if(diagnosisStatus==2) {
                            diagnosisStatusName = '无症状感染者'
                        } else if(diagnosisStatus==3) {
                            diagnosisStatusName = '阴性'
                        }
                        return h('span', {
                            domProps: {
                                innerHTML: diagnosisStatusName
                            }
                        })
                    }
                },
                // {
                //     title: "状态",
                //     key: "tubesStatusName",
                //     align: "center",
                //     render:(h,params)=>{
                //         let transferStatus = params.row.transferStatus
                //         let diagnosisStatus = params.row.diagnosisStatus
                //         let tubesStatusName = ''
                //         if(transferStatus==0 && diagnosisStatus==0) {
                //             tubesStatusName = '未确诊，未流调'
                //         } else if(transferStatus==1 && diagnosisStatus==0) {
                //             tubesStatusName = '未确诊，已流调'
                //         } else if(transferStatus==0 && diagnosisStatus==1) {
                //             tubesStatusName = '已确诊，未流调'
                //         } else if(transferStatus==1 && diagnosisStatus==1) {
                //             tubesStatusName = '已确诊，已流调'
                //         }
                //         return h('span', {
                //             domProps: {
                //                 innerHTML: tubesStatusName
                //             }
                //         })
                //     }
                // },
                {
                    title: "设置",
                    key: "operate",
                    align: "center",
                    // width: 60,
                    render: (h, params) => {
                        let tubesStatus = params.row.tubesStatus
                        let tubesId = params.row.id;
                        let transferStatus = params.row.transferStatus
                        let diagnosisStatus = params.row.diagnosisStatus
                        let reportUrl = params.row.reportUrl
                        return [
                            h(
                                "a",
                                {
                                    attrs: {
                                        href: "javascript:void(0);"
                                    },
                                    style: {
                                        color: " #5362e1",
                                        width: "60px"
                                    },
                                    on: {
                                        click: () => {
                                            if(reportUrl) {
                                                // window.open('https://' + reportUrl);
                                                window.open(reportUrl);
                                            } else {
                                                this.$Message.info("该条记录暂未上传链接地址");
                                            }
                                        }
                                    }
                                },
                                "检验报告"
                            ),
                            // transferStatus==0 ?
                            // h(
                            //     "a",
                            //     {
                            //         attrs: {
                            //             href: "javascript:void(0);"
                            //         },
                            //         style: {
                            //             color: " #21c780",
                            //             width: "60px"
                            //         },
                            //         on: {
                            //             click: () => {
                            //                 this.moveModal = true
                            //                 this.tubesId = tubesId
                            //             }
                            //         }
                            //     },
                            //     "移交流调"
                            // ) : '',
                            diagnosisStatus==0 ?
                            h(
                                "a",
                                {
                                    attrs: {
                                        href: "javascript:void(0);"
                                    },
                                    style: {
                                        color: " #fc6c49",
                                        width: "60px"
                                    },
                                    on: {
                                        click: () => {
                                            this.confirmModal = true
                                            this.tubesId = tubesId
                                        }
                                    }
                                },
                                "处理确诊"
                            ) : '',
                        ]
                    }
                }
            ],
            column4: [
                {
                    title: "排序",
                    key: "iSum",
                    align: "center",
                    width: 70,
                    render: (h, params) => {
                        let iSum = (this.pageNo-1)*this.pageSize + params.index +1;
                        return h("span", iSum);
                    }
                },
                {
                    title: "姓名",
                    key: "name",
                    align: "center"
                },
                {
                    title: "身份证号",
                    key: "idcard",
                    align: "center"
                },
                {
                    title: "手机号",
                    key: "telephone",
                    align: "center",
                    // width: 200
                },
                {
                    title: "采集点",
                    key: "locationName",
                    align: "center",
                    // width: 200
                },
                {
                    title: "实际采集地点",
                    key: "taskLocation",
                    align: "center",
                },
                {
                    title: "采集类型",
                    key: "collcectType",
                    align: "center",
                    render:(h,params)=>{
                        let collcectType = params.row.collcectType
                        let collcectTypeName = ''
                        if(collcectType==0) {
                            collcectTypeName = '定点'
                        } else if(collcectType==1) {
                            collcectTypeName = '上门'
                        }
                        return h('span', {
                            domProps: {
                                innerHTML: collcectTypeName
                            }
                        })
                    }
                },
                {
                    title: "样本编号",
                    key: "tubesCode",
                    align: "center",
                },
                {
                    title: "采集时间",
                    key: "collectionTime",
                    align: "center",
                },
                // {
                //     title: "流调状态",
                //     key: "tubesStatusName",
                //     align: "center",
                //     render:(h,params)=>{
                //         let transferStatus = params.row.transferStatus
                //         let tubesStatusName = ''
                //         if(transferStatus==0) {
                //             tubesStatusName = '未流调'
                //         } else if(transferStatus==1) {
                //             tubesStatusName = '已流调'
                //         }
                //         return h('span', {
                //             domProps: {
                //                 innerHTML: tubesStatusName
                //             }
                //         })
                //     }
                // },
                {
                    title: "确诊结果",
                    key: "diagnosisStatus",
                    align: "center",
                    render:(h,params)=>{
                        let diagnosisStatus = params.row.diagnosisStatus
                        let diagnosisStatusName = ''
                        if(diagnosisStatus==0) {
                            diagnosisStatusName = '未处理'
                        } else if(diagnosisStatus==1) {
                            diagnosisStatusName = '确诊病例'
                        } else if(diagnosisStatus==2) {
                            diagnosisStatusName = '无症状感染者'
                        } else if(diagnosisStatus==3) {
                            diagnosisStatusName = '阴性'
                        }
                        return h('span', {
                            domProps: {
                                innerHTML: diagnosisStatusName
                            }
                        })
                    }
                },
                {
                    title: "设置",
                    key: "operate",
                    align: "center",
                    // width: 60,
                    render: (h, params) => {
                        let tubesStatus = params.row.tubesStatus
                        let tubesId = params.row.id;
                        let transferStatus = params.row.transferStatus
                        let diagnosisStatus = params.row.diagnosisStatus
                        let reportUrl = params.row.reportUrl
                        return [
                            h(
                                "a",
                                {
                                    attrs: {
                                        href: "javascript:void(0);"
                                    },
                                    style: {
                                        color: " #5362e1",
                                        width: "60px"
                                    },
                                    on: {
                                        click: () => {
                                            window.open(reportUrl);
                                        }
                                    }
                                },
                                "检验报告"
                            ),
                            // transferStatus==0 ?
                            // h(
                            //     "a",
                            //     {
                            //         attrs: {
                            //             href: "javascript:void(0);"
                            //         },
                            //         style: {
                            //             color: " #21c780",
                            //             width: "60px"
                            //         },
                            //         on: {
                            //             click: () => {
                            //                 this.moveModal = true
                            //                 this.tubesId = tubesId
                            //             }
                            //         }
                            //     },
                            //     "移交流调"
                            // ) : '',
                            diagnosisStatus==0 ?
                            h(
                                "a",
                                {
                                    attrs: {
                                        href: "javascript:void(0);"
                                    },
                                    style: {
                                        color: " #fc6c49",
                                        width: "60px"
                                    },
                                    on: {
                                        click: () => {
                                            this.confirmModal = true
                                            this.tubesId = tubesId
                                        }
                                    }
                                },
                                "处理确诊"
                            ) : '',
                        ]
                    }
                }
            ],
            count: 0,
            pageSize: 10,
            pageNo: 1,
            tasklist: [],
            locationlist: [],
            sampleApi: api.getCollectTubesIpage,     //样本列表api
            invalidApi: api.getNullifyCollectAppointmentTubesIpage,     //作废样本列表api
            positiveApi: api.getPositiveCollectAppointmentTubesIpage,     //阳性列表api
            listApi: api.getCollectTubesIpage,
            listText: '样本列表',
            moveModal: false,
            confirmModal: false,
            invalidNum: '',
            positiveNum: '',
            transferStatus: '',
            disabledWZZ: false,
            disabledQZ: false,
            disabledYY: false,
            neglectModal: false,
            disabledNeglect: false,
            id: '',
        }
    },
    created() {},
    mounted() {
        this.typeStatus = this.$route.query.typeStatus ? this.$route.query.typeStatus : 1;
        this.pageNo = this.$route.query.pageNo ? this.$route.query.pageNo : 1;
        this.columns = this.column1
        this.gettasklist()
        this.getlocationlist()
        this.getInvalidNum()
        this.getPositiveNum()
        this.loadPage(1);
    },
    methods: {
        changeTab(item) {
            if(item) {
                this.typeStatus = item
            }
            if(this.typeStatus ==1 ) {
                this.columns = this.column1
                this.listApi = this.sampleApi
                this.listText = '样本列表'
            } else if(this.typeStatus ==2 ) {
                this.columns = this.column2
                this.listApi = this.invalidApi
                this.listText = '作废样本人员'
            } else if(this.typeStatus ==3 ) {
                this.columns = this.column3
                this.listApi = this.positiveApi
                this.listText = '阳性样本人员'
            }
            this.info = {
                taskName: null,
                taskId: null,
                taskLocationId: null,
                tubesStatus: null,
                endTime: null,
                boxCode: null,
                tubesCode: null,
            }
            this.transferStatus = null
            this.loadPage(1)
        },
        //作废样本人员未处理数量
        getInvalidNum() {
            var params = {}
            params.taskLocationId = this.info.taskLocationId ? this.info.taskLocationId : null
            this.$axios
                .post(api.getNullifyManageTubesIpage, params )
                .then(resp => {
                    if (resp.data.success) {
                        this.invalidNum = resp.data.object.count;
                    } else {
                        this.$Message.info("不允许访问");
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
        //阳性样本人员未移交数量
        getPositiveNum() {
            var params = {}
            params.taskLocationId = this.info.taskLocationId ? this.info.taskLocationId : null
            this.$axios
                .post(api.getPositiveManageTubesIpage, params )
                .then(resp => {
                    if (resp.data.success) {
                        this.positiveNum = resp.data.object.count;
                    } else {
                        this.$Message.info("不允许访问");
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
        getdatalist(pageNo,val) {
            console.log(val)
            this.pageNo = pageNo
            let params = {
                pageNo: this.pageNo,
                pageSize: 10,
                tubesId: val ? val : this.tubesId
            }
            this.$axios
                .post(api.getCollectTubesDetailsIpage, params)
                .then(resp => {
                    if (resp.data.success) {
                        this.count = resp.data.object.total
                        if(resp.data.object.records) {
                            this.datalist = resp.data.object.records;
                        } else {
                            this.datalist = []
                        }
                    } else {
                        this.datalist = []
                        this.$Message.info("不允许访问");
                    }
                })
                .catch(err => {
                    this.datalist = []
                    console.log(err);
                });
        },
        //获取任务列表数据
        gettasklist() {
            var params = {};
            params.pageNo = 1;
            params.pageSize = 10000;
            this.$axios
                .post(api.queryTaskList, params)
                .then(resp => {
                    if (resp.data.success) {
                        if(resp.data.object.records) {
                            this.tasklist = resp.data.object.records;
                        } else {
                            this.tasklist = []
                        }
                    } else {
                        this.$Message.info("不允许访问");
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
        //获取采集点列表
        getlocationlist() {
            var params = {};
            params.searchStatus = 1;
            params.pageNo = 1;
            params.pageSize = 10000;
            this.$axios
                .post(api.findLocationPage, params)
                .then(resp => {
                    if (resp.data.success) {
                        if(resp.data.object.records) {
                            this.locationlist = resp.data.object.records;
                        } else {
                            this.locationlist = []
                        }
                    } else {
                        this.$Message.info("不允许访问");
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
        //加载列表数据
        loadPage(pageNo) {
            if(this.typeStatus == 1) {
                this.info.tubesStatus = this.info.tubesStatus ? this.info.tubesStatus : null
            } else if(this.typeStatus == 2) {
                this.info.statusList = [2]
                // if(this.info.tubesStatus){
                //     this.info.statusList.push(this.info.tubesStatus)
                // }
            }
            // else if(this.typeStatus == 3) {
            //     if(this.transferStatus == 1) {
            //         this.info.transferStatus = 0
            //         this.info.diagnosisStatus = 0
            //     } else if(this.transferStatus == 2) {
            //         this.info.transferStatus = 1
            //         this.info.diagnosisStatus = 0
            //     } else if(this.transferStatus == 3) {
            //         this.info.transferStatus = 0
            //         this.info.diagnosisStatus = 1
            //     } else if(this.transferStatus == 4) {
            //         this.info.transferStatus = 0
            //         this.info.diagnosisStatus = 1
            //     }
            // }
            this.pageNo = pageNo
            this.info.pageNo = pageNo
            this.info.pageSize = this.pageSize
            this.info.taskId = this.info.taskId ? this.info.taskId : null
            this.info.taskLocationId = this.info.taskLocationId ? this.info.taskLocationId : null
            this.info.boxCode = this.info.boxCode ? this.info.boxCode : null
            this.info.tubesCode = this.info.tubesCode ? this.info.tubesCode : null
            this.info.diagnosisStatus = this.info.diagnosisStatus ? this.info.diagnosisStatus : null
            this.info.endTime = this.info.endTime ? Utils.getNowDateBySpecialFormat(this.info.endTime) : null
            this.$axios.post(this.listApi, this.info).then(resp => {
                if (resp.data.code == 1) {
                    let ret = resp.data.object;
                    this.count = ret.total
                    if(ret.records){
                        this.datalist = ret.records;
                    } else {
                        this.datalist = [];
                        this.count = 0
                    }
                } else {
                    this.$Message.error(resp.data.message);
                    this.datalist = [];
                    this.count = 0
                }
            })
            .catch(err => {
                console.log(err);
            });
        },
        //按筛选条件导出
        download() {
            let url = api.tubesListExport
            if(this.typeStatus ==1 ) {
                url = api.tubesListExport
            } else if(this.typeStatus ==2 ) {
                url = api.nullifyAppointmentListExport
            } else if(this.typeStatus ==3 ) {
                url = api.positiveAppointmentListExport
            }
            let params = {}
            params.taskId = this.info.taskId ? this.info.taskId : null
            params.taskLocationId = this.info.taskLocationId ? this.info.taskLocationId : null
            params.tubesStatus = this.info.tubesStatus ? this.info.tubesStatus : null
            params.boxCode = this.info.boxCode ? this.info.boxCode : null
            params.tubesCode = this.info.tubesCode ? this.info.tubesCode : null
            params.diagnosisStatus = this.info.diagnosisStatus ? this.info.diagnosisStatus : null
            params.endTime = this.info.endTime ? Utils.getNowDateBySpecialFormat(this.info.endTime) : null
            const link = document.createElement('a')
            this.$axios.post(url, params, { responseType: "arraybuffer" }).then(res =>{
                if (res.data) {
                    let ret = res.data;
                    // var blob = new Blob([ret],{ type:"application/vnd.ms-excel" });
                    // let objUrl = URL.createObjectURL(blob);
                    // window.location.href = objUrl;
                    let blob = new Blob([ret], {type: "application/vnd.ms-excel"})
                    let objectUrl = URL.createObjectURL(blob) // 创建URL
                    link.href = objectUrl
                    link.download = this.listText // 自定义文件名
                    link.click() // 下载文件
                    URL.revokeObjectURL(objectUrl); // 释放内存
                }
            })
        },
        back() {
            this.positive = false
            this.columns = this.column1
            this.changeTab(1)
            this.loadPage(1)
        },
        //移交流调
        movesubmit() {
            this.$axios
                .post(api.flowModulatioTtransfer, {id: this.tubesId})
                .then(resp => {
                    if (resp.data.success) {
                        this.$Message.success(resp.data.object.message);
                    } else {
                        this.$Message.info("不允许访问");
                    }
                })
                .catch(err => {
                    console.log(err);
                });
        },
        //提交确诊
        confirmsubmit(val) {
            if(val== 1) {
                this.disabledQZ = true
            } else if(val== 2) {
                this.disabledWZZ = true
            } else if(val== 3) {
                this.disabledYY = true
            }
            this.$axios
                .post(api.diagnosisTtransfer, {id: this.tubesId,diagnosisStatus: val,})
                .then(resp => {
                    if (resp.data.success) {
                        this.$Message.success(resp.data.message);
                        if(val== 1) {
                            this.disabledQZ = false
                        } else if(val== 2) {
                            this.disabledWZZ = false
                        } else if(val== 3) {
                            this.disabledYY = false
                        }
                        this.confirmModal = false
                        this.loadPage(1)
                    } else {
                        if(val== 1) {
                            this.disabledQZ = false
                        } else if(val== 2) {
                            this.disabledWZZ = false
                        } else if(val== 3) {
                            this.disabledYY = false
                        }
                        this.$Message.info("不允许访问");
                    }
                })
                .catch(err => {
                    if(val== 1) {
                            this.disabledQZ = false
                        } else if(val== 2) {
                            this.disabledWZZ = false
                        } else if(val== 3) {
                            this.disabledYY = false
                        }
                    console.log(err);
                });
        },
        //忽略
        neglectsubmit() {
            this.disabledNeglect = true
            this.$axios.post(api.tubesIgnore, {id: this.id} )
                .then(resp => {
                    if (resp.data.success) {
                        this.disabledNeglect = false
                        this.neglectModal = false
                        this.$Message.success(resp.data.message)
                        this.loadPage(1)
                        this.getInvalidNum()
                    } else {
                        this.disabledNeglect = false
                        this.$Message.info("不允许访问");
                    }
                })
                .catch(err => {
                    this.disabledNeglect = false
                    console.log(err);
                });
        },
    },
}
</script>

<style lang="less" scoped>
.test {
    width: calc(100%);
    padding: 10px 30px;
    margin: 0 auto;
    background: #fff;
    min-height: 600px;
    .tmpHeader {
        width: 100%;
        height: 40px;
        border-bottom: 2px solid #f2f2f2;
        margin-top: 20px;
        span {
            display: inline-block;
            line-height: 38px;
            padding: 0 15px;
            cursor: pointer;
            border-bottom: 2px solid transparent;
            transition: all 0.5s;
            position: relative;
        }
        span.active {
            color: #5362e1;
            border-bottom: 2px solid #5362e1;
        }
        span:hover {
            border-bottom: 2px solid #5362e1;
            color: #5362e1;
        }
        .num {
            min-width: 20px;
            height: 20px;
            background-color: #f56c6c;
            border-radius: 10px;
            padding: 5px;
            font-size: 4px;
            line-height: 15px;
            position: absolute;
            top: -5px;
            right: -2px;
        }
    }
    .margin-up-down {
        display: inline-block;
        margin: 10px 0;
    }
    .cueBox {
        background-color: #fef0f0;
        display: flex;
        padding: 5px 0 5px 15px;
        .icon {
            vertical-align: middle;
            margin-right: 15px;
            img {
                width: 35px;
                height: 35px;
            }
        }
        .cue {
            .s1 {
                color: #f56c6c;
                font-weight: bold;
            }
            .s2 {
                color: #f56c6c;
            }
        }
    }
    .page{
        text-align: center;
        margin: 20px 0;
    }
    .btn {
        width: 75px;
        height: 35px;
    }
}
.txtword {
    // text-align: center;
    margin-left: 30px;
}
</style>